Get the permissions in a module

Hello,

 

I want to get the module's access to know which users and groups have access to the module. I know how to do it for the attributes, views, types,...but not for the module's access.

 

Thank you!


Juanfergar - Tue Jun 11 03:06:07 EDT 2019

Re: Get the permissions in a module
Mike.Scharnow - Tue Jun 11 17:19:52 EDT 2019

I don't understand - there is no difference between AccessRecs of attributes and modules.

 

So, a simple 

AccessRec ar; Module m = ...; for ar in m do {...}

should do the trick.

Re: Get the permissions in a module
Juanfergar - Wed Jun 12 02:19:02 EDT 2019

Mike.Scharnow - Tue Jun 11 17:19:52 EDT 2019

I don't understand - there is no difference between AccessRecs of attributes and modules.

 

So, a simple 

AccessRec ar; Module m = ...; for ar in m do {...}

should do the trick.

Thank you for the answer.

 

I know how to go throw every access, but I don't know how to print them. In the example show the name of the user ("string user = username ar")  but if the access is for a group I can't print it. Or if the access is "Everyone else" neither.

 

An example of what I did is:

 

Module m = ...
AccessRec ar
int i = 0
for ar in m do{
    i++
    print i "\n"
}

But never print 

Re: Get the permissions in a module
Mike.Scharnow - Wed Jun 12 03:06:21 EDT 2019

Juanfergar - Wed Jun 12 02:19:02 EDT 2019

Thank you for the answer.

 

I know how to go throw every access, but I don't know how to print them. In the example show the name of the user ("string user = username ar")  but if the access is for a group I can't print it. Or if the access is "Everyone else" neither.

 

An example of what I did is:

 

Module m = ...
AccessRec ar
int i = 0
for ar in m do{
    i++
    print i "\n"
}

But never print 

Something like this should work:


for ar in m do {
    string userOrGroup = username ar
    if (null userOrGroup) {
        print "Everyone Else: "
    } else {
        if (existsGroup (userOrGroup)) {
            print "Group " userOrGroup ": "
        } else {
            print "User " userOrGroup ": "
        }
    }
    if (modify ar) {
        print "can modify\n"
    } else {
        print "cannot modify\n"
    }
}

For sanity, you could add a condition if not existsUser (userOrGroup) to find accessrecordsr for deleted users/groups. Should not occur.

Re: Get the permissions in a module
Juanfergar - Wed Jun 12 04:38:57 EDT 2019

Mike.Scharnow - Wed Jun 12 03:06:21 EDT 2019

Something like this should work:


for ar in m do {
    string userOrGroup = username ar
    if (null userOrGroup) {
        print "Everyone Else: "
    } else {
        if (existsGroup (userOrGroup)) {
            print "Group " userOrGroup ": "
        } else {
            print "User " userOrGroup ": "
        }
    }
    if (modify ar) {
        print "can modify\n"
    } else {
        print "cannot modify\n"
    }
}

For sanity, you could add a condition if not existsUser (userOrGroup) to find accessrecordsr for deleted users/groups. Should not occur.

That seems perfect, but now my problem is that neve enter in the for, I mean, in my example:

Module m = ...
AccessRec ar
int i = 0
for ar in m do{
    i++
    print i "\n"
}

Print nothing, because doesn't enter in the for.

Re: Get the permissions in a module
Mike.Scharnow - Wed Jun 12 06:10:19 EDT 2019

Juanfergar - Wed Jun 12 04:38:57 EDT 2019

That seems perfect, but now my problem is that neve enter in the for, I mean, in my example:

Module m = ...
AccessRec ar
int i = 0
for ar in m do{
    i++
    print i "\n"
}

Print nothing, because doesn't enter in the for.

That means that your module has no own access records (Module -> Properties -> Access -> Inherit from parent = true), i.e. the module inherits the access rights from its parent.

You can check this with the perm 

string isAccessInherited(Module m,[AttrType at,]bool &inherited)

If you want to see the effective access rights, you can use the loop





 

By the way: see http://www.smartdxl.com/content/?p=388 and http://www.smartdxl.com/content/?p=385 for scripts dealing with access rights.

 

Update: hm, seems that the screenshot is not shown correctly. The loop is "for ar in all item", (page 475 of the reference manual)

 

Re: Get the permissions in a module
Juanfergar - Wed Jun 12 06:21:37 EDT 2019

Mike.Scharnow - Wed Jun 12 06:10:19 EDT 2019

That means that your module has no own access records (Module -> Properties -> Access -> Inherit from parent = true), i.e. the module inherits the access rights from its parent.

You can check this with the perm 

string isAccessInherited(Module m,[AttrType at,]bool &inherited)

If you want to see the effective access rights, you can use the loop





 

By the way: see http://www.smartdxl.com/content/?p=388 and http://www.smartdxl.com/content/?p=385 for scripts dealing with access rights.

 

Update: hm, seems that the screenshot is not shown correctly. The loop is "for ar in all item", (page 475 of the reference manual)

 

Perfect! It was because all the modules I was checking were with Inherit. So with this and your answer before I can know all the permissions in the modules.


Tank you!!!